package com.wn.cl.park.model.enums;

import lombok.Getter;

@Getter
public enum DmhStatus {
    //订单状态（0-已锁定未支付, 1-已支付未入场, 2-已完成, 3-支付后取消，4、超时未入场，5未支付取消）
    RESERVATIONS_LOCK(0, "已锁定未支付"),
    RESERVATIONS_PAY(1, "已支付未入场"),
    RESERVATIONS_COMPLETE(2, "已完成"),
    RESERVATIONS_CANCEL(3, "支付后取消"),
    RESERVATIONS_TIMEOUT(4, "超时未入场"),
    RESERVATIONS_NO_PAY(5, "未支付取消"),

    //未占用，已占用
    SPOT_NO_RECEIVE(0, "未占用"),
    SPOT_LOCK(1, "锁定"),
    SPOT_RECEIVE(2, "已占用"),

    //支付状态：0支付中，1成功，2失败,3超时未支付
    PAYMENTS_PAYING(0, "支付中"),
    PAYMENTS_PAY_SUCCESS(1, "支付成功"),
    PAYMENTS_PAY_FAIL(2, "支付失败"),
    PAYMENTS_PAY_TIMEOUT(3, "超时未支付"),

    //"0 - 待支付	1 - 支付成功	2 - 待服务	3 - 服务中	4 - 服务完成	5 - 待评价	6 - 已评价	7 - 取消	8 - 退款中	9 - 退款成功"
    ORDER_PAYING(0, "待支付"),
    ORDER_PAY_SUCCESS(1, "支付成功"),
    ORDER_PAY_SERVICE(2, "待服务"),
    ORDER_PAY_SERVICE_ING(3, "服务中"),
    ORDER_PAY_SERVICE_END(4, "服务完成"),
    ORDER_PAY_EVALUATE(5, "待评价"),
    ORDER_PAY_EVALUATE_END(6, "已评价"),
    ORDER_PAY_CANCEL(7, "取消"),
    ORDER_PAY_REFUND(8, "退款中"),
    ORDER_PAY_REFUND_END(9, "退款成功");


    ;



    private Integer code;
    private String describe;
    DmhStatus(int code, String describe) {
        this.code = code;
        this.describe = describe;
    }
    /**
     * 通过编码找到枚举对象
     */
    public static DmhStatus matchCode(int code) {
        DmhStatus status = null;
        //values()方法是枚举类自带的方法，获取当前所有枚举项的数组
        DmhStatus[] values = values();
        for (DmhStatus value : values) {
            if (value.getCode() == code) {
                status = value;
                break;
            }
        }
        return status;
    }
    /**
     * 通过描述找到枚举对象
     */
    public static DmhStatus matchDescribe(String describe) {
        DmhStatus status = null;
        DmhStatus[] values = values();
        for (DmhStatus OrderStatus : values) {
            if (OrderStatus.getDescribe().equals(describe)) {
                status = OrderStatus;
                break;
            }
        }
        return status;
    }
}